package cn.ac.big.bigd.gsa.dao;


import cn.ac.big.bigd.gsa.model.Sex;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *@Author wangfan
 *@Date 2016/11/29 15:49
 */
@Repository
public interface GsaDao extends JpaRepository<Sex, Integer> {



    @Query(value = "SELECT project.accession FROM project INNER JOIN USER WHERE " +
            "project.`user_id`=user.`user_id` AND project.`accession` IS NOT NULL AND project.`accession` != '' AND user.`email`=?1", nativeQuery = true)
    List<String>  findProAccessionByUser(String user);


    @Query(value = "SELECT sample.accession FROM sample INNER JOIN USER WHERE sample.`user_id`=user.`user_id` AND sample.`accession` IS NOT NULL AND sample.`accession` != '' AND user.`email`=?1", nativeQuery = true)
    List<String>  findSamAccessionByUser(String user);



    @Query(value = "SELECT sample.accession FROM sample INNER JOIN USER WHERE sample.`user_id`=user.`user_id` " +
            "AND sample.`accession` IS NOT NULL AND sample.`accession` != '' AND user.`email`=?1", nativeQuery = true)
    List<String>  findByAccession(String accession);

}
